home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / misc / MapMaster.lha / mapmaster / amosprosupport / examplecode.amos / examplecode.amosSourceCode < prev    next >
Encoding:
AMOS Source Code  |  1997-08-18  |  2.0 KB  |  60 lines

  1. Rem MapMaster V1.0 Example code. 
  2. Rem This Example shows you how easy it is to use the included procedures.  
  3. Rem It allows you to move through a map with the joystick. 
  4. Rem Push mouse key to quit.  
  5.  
  6. Rem /*--- Set up variables ---*/       
  7. Dim BLOCKS(240)
  8. Global BLOCKS()
  9. X=0
  10. Y=0
  11.  
  12. Rem /* Open required Screen */ 
  13. Screen Open 1,320,200,32,Lowres : Flash Off : Curs Off 
  14.  
  15. Rem /*--- Call the routines with correct parameters ---*/
  16. _LOADMAP["map1",20,12]
  17. _GETBLOCKS["dungeonblocks.iff",16,16,1]
  18. _PASTEBLOCKS[16,16,20,12,X,Y]
  19.  
  20. Rem /*--- Handle the movement ---*/
  21. Repeat 
  22. If Jleft(1) Then X=X-1 : _PASTEBLOCKS[16,16,20,12,X,Y]
  23. If Jright(1) Then X=X+1 : _PASTEBLOCKS[16,16,20,12,X,Y]
  24. If Jup(1) Then Y=Y-1 : _PASTEBLOCKS[16,16,20,12,X,Y]
  25. If Jdown(1) Then Y=Y+1 : _PASTEBLOCKS[16,16,20,12,X,Y]
  26. Multi Wait 
  27. Until Mouse Key=1
  28. End 
  29.  
  30. Procedure _LOADMAP[_MAP$,_HORIZBLOCKS,_VERTBLOCKS]
  31. Open In 1,_MAP$
  32. NUM=1
  33. Repeat 
  34. Input #1,BLOCKS(NUM)
  35. NUM=NUM+1
  36. Until NUM=_HORIZBLOCKS*_VERTBLOCKS+1
  37. Close 1
  38. End Proc
  39. Procedure _GETBLOCKS[_BLOCKSFILE$,_BLOCKWIDTH,_BLOCKHEIGHT,_BLOCKGAP]
  40. NUM=1 : X=_BLOCKGAP : Y=_BLOCKGAP : _TOTALWIDTH=Screen Width/(_BLOCKWIDTH+_BLOCKGAP) : WIDTH2=_TOTALWIDTH
  41. Load Iff _BLOCKSFILE$
  42. Repeat 
  43. If NUM=WIDTH2 and X+_BLOCKWIDTH>Screen Width Then X=_BLOCKGAP : Y=Y+_BLOCKHEIGHT+_BLOCKGAP : WIDTH2=WIDTH2+_TOTALWIDTH
  44. If NUM<WIDTH2 Then Get Block NUM,X,Y,_BLOCKWIDTH,_BLOCKHEIGHT,1 : X=X+_BLOCKWIDTH+_BLOCKGAP Else Get Block NUM,X,Y,_BLOCKWIDTH,_BLOCKHEIGHT,1 : X=_BLOCKGAP : Y=Y+_BLOCKHEIGHT+_BLOCKGAP : WIDTH2=WIDTH2+_TOTALWIDTH
  45. If Y+_BLOCKHEIGHT>=Screen Height Then Y=Screen Height
  46. NUM=NUM+1
  47. Until Y>=Screen Height
  48. End Proc
  49. Procedure _PASTEBLOCKS[_BLOCKWIDTH,_BLOCKHEIGHT,_HORIZBLOCKS,_VERTBLOCKS,XSET,YSET]
  50. Rem /*--- Set Variables to suitable Values ---*/ 
  51. NUM=1 : X=XSET*_BLOCKWIDTH : Y=0+YSET*_BLOCKHEIGHT : NUM2=2
  52. Cls 0
  53. Repeat 
  54. Put Block BLOCKS(NUM),X,Y
  55. X=X+_BLOCKWIDTH
  56. If NUM=_HORIZBLOCKS Then Y=Y+_BLOCKHEIGHT : X=XSET*_BLOCKWIDTH
  57. If NUM=_HORIZBLOCKS*NUM2 Then Y=Y+_BLOCKHEIGHT : X=XSET*_BLOCKWIDTH : NUM2=NUM2+1
  58. NUM=NUM+1
  59. Until NUM=_HORIZBLOCKS*_VERTBLOCKS+1
  60. End Proc